//
//  LoginHeader.h
//  MPWeChatDemo
//
//  Created by HappyMilk 01 on 2017/5/1.
//  Copyright © 2017年 srulos. All rights reserved.
//

#ifndef LoginHeader_h
#define LoginHeader_h

#import "LibHeader.h"
#import "QRCodeLoginViewController.h"
#import "LeanCloudLoginViewController.h"
#import "LeanCloudLoginViewController.h"
#import "MPWeChat.h"
#import "MBProgressHUD.h"
#import <AVOSCloud/AVOSCloud.h>
#import "MyAdTools.h"

#define AD_TEST_CY @"ca-app-pub-4634576436183649/9922325010"
#define AD_TEST_YS @"ca-app-pub-3940256099942544/2562852117"
#define AD_TEST_HF @"ca-app-pub-4634576436183649/5385133417"

#define IS_IPAD [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad

#define IS_PASS ([MPWeChat stander].m_adStatus>0 || [MPWeChat stander].m_needLogin)

#define LOC_STR(str)  NSLocalizedStringFromTable(str, @"Login", nil)

//中文
#define IS_CHINESE [[[NSLocale preferredLanguages] objectAtIndex:0] containsString:@"zh-Han"]

#define IsNilString(__String) (__String==nil || [__String isEqualToString:@""]|| [__String isEqualToString:@"null"] || [__String isEqualToString:@"(null)"] || [__String isEqualToString:@"<null>"] || [__String isEqual:@""])

#define HEXCOLOR(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

#define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
#define RGB(r,g,b) RGBA(r,g,b,1.0f)

#define __kwidth [UIScreen mainScreen].bounds.size.width
#define __kheight [UIScreen mainScreen].bounds.size.height

//hud
#define SHOW_HUD(_text)\
MBProgressHUD * progressHUD = [[MBProgressHUD alloc] initWithView:self.view];\
progressHUD.labelText = _text;\
[self.view addSubview:progressHUD];\
[self.view bringSubviewToFront:progressHUD];\
[progressHUD show:YES];\
[progressHUD hide:YES afterDelay:20];

#define SHOW_HUD_MESSAGE(title)\
MBProgressHUD * hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];\
hud.mode = MBProgressHUDModeText;\
CGFloat animationTime = title.length / 12.0f;\
if (animationTime < 1.0) {\
animationTime = 1.5;\
}\
[hud hide:YES afterDelay:animationTime];\
if(title.length > 15){\
[hud setDetailsLabelText:title];\
}\
else{\
[hud setLabelText:title];\
}

#define HIDE_HUD [MBProgressHUD hideHUDForView:self.view animated:YES];

#define SHOW_LOGIN_VIEW_CONTROLLER(_color)\
if([MPWeChat stander].m_isLogin == false){\
LeanCloudLoginViewController * leanCloudViewController = [[LeanCloudLoginViewController alloc]initWithNibName:@"LeanCloudLoginViewController" bundle:nil];\
leanCloudViewController.mainColor = _color;\
UINavigationController * navigationController = [[UINavigationController alloc]initWithRootViewController:leanCloudViewController];\
[self presentViewController:navigationController animated:YES completion:nil];\
return;\
}\


#define VC_INIT_WITH_STORYBOARD(sb_name,class_name,vc_name)\
class_name *vc_name = [[UIStoryboard storyboardWithName:@#sb_name bundle:nil] instantiateViewControllerWithIdentifier:@#class_name];




#endif /* LoginHeader_h */
